from request.package.dorequest import DoRequest
from request.package.item import item,fetch

d=DoRequest()
tid='tenant_021052'
cid='company_000548'
eid='employee_000997'
token='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0ZW5hbnRJZCI6InRlbmFudF8wMjEwNTIiLCJsb2dpblRva2VuIjoiZjZmZDhjM2EtZGY5Ni00MjBhLWFjOWUtYWVjMmQ3NjZhMDVkIiwidXNlcklkIjoiMTM4MDAyMjgwMDAifQ.lISpbsWbkgBiRZq0SN1RmAPq2RRM4thAFjxKtz7XfxQ'
st_day='2020-06-07'
st_time='14:00'
end_time='15:00'
hours='1.00'
end_day=''
if end_day=='':
    end_day=st_day


# a=item('请假','http',{'method':'post','url':'https://paytest.ciicsh.com/applet/leave/saveEmployeeLeave','data':{"id":"","leaveStatus":1,"leaveFileList":[],"companyId":"company_000477","employeeId":"employee_000932","employeeName":"爱华仕","userId":"13800226000","reason":"您","dateStar":"2020-06-05 10:24","dateEnd":"2020-06-05 11:24","dateStarShow":"2020-06-05 10:24","dateEndShow":"2020-06-05 11:24","holidayTypeName":"带薪休假","holidayUnitName":"天","hourCount":"0.50","holidayTypeId":5331},'headers':{'authorization':'bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0ZW5hbnRJZCI6InRlbmFudF8wMjA5ODEiLCJsb2dpblRva2VuIjoiYjJjMWQ2YmMtMTc0OC00ZjJhLWJhYWYtMjdiYTZkZjE3NDk0IiwidXNlcklkIjoiMTM4MDAyMjYwMDAifQ.1MBi_a2HzzvemzyhGU5paDdx3dBbo9hjIsQ8XbhoZ-s','tenantid':'tenant_020981','x-tag':'flyio'}}).run(d).expect('data.code','json').toBe(0)
# a=item('加班','http',{'method':'post','url':'https://paytest.ciicsh.com/applet/overtime/submitOvertime','data':{"tenantId":tid,"companyId":cid,"employeeId":eid,"overtimeType":1,"startDate":st_day+" "+st_time,"endDate":end_day+" "+end_time,"consumeHours":"1.00","applyReason":"席子营","createdBy":"13800228000","applyUserName":"女的1","pictureList":[]},'headers':{'authorization':'bearer '+token,'tenantid':tid,'x-tag':'flyio'}}).expect('data.code','json').toBe(0).run(d)
# SELECT * FROM `saas_business`.`holiday_type` WHERE tenant_id='tenant_021052' and  `name`='年假否显示是范围全单位小时包法定否附件否'
# a=item('小时假','http',{'method':'post','url':'https://paytest.ciicsh.com/applet/leave/saveEmployeeLeave','data':{"id":"","leaveStatus":1,"leaveFileList":[],"companyId":cid,"employeeId":eid,"employeeName":"爱华仕","userId":"13800228000","reason":"哺乳假","dateStar":st_day+" "+st_time,"dateEnd":end_day+" "+end_time,"dateStarShow":st_day+" "+st_time,"dateEndShow":end_day+" "+end_time,"holidayTypeName":"年假否显示是范围全单位小时包法定否附件否","holidayUnitName":"小时","hourCount":"1.00","holidayTypeId":22067},'headers':{'authorization':'bearer '+token,'tenantid':tid,'x-tag':'flyio'}}).expect('data.code','json').toBe(0).run(d)
# a=item('外出','http',{'method':'post','url':'https://paytest.ciicsh.com/applet/officialBusiness/submitOfficialBusiness','data':{"tenantId":tid,"companyId":cid,"employeeId":eid,"startDate":st_day+" "+st_time,"endDate":end_day+" "+end_time,"consumeHours":hours,"applyReason":"路路通","createdBy":"13800228000","applyUserName":"女的1","pictureList":[]},'headers':{'authorization':'bearer '+token,'tenantid':tid,'x-tag':'flyio'}}).expect('data.code','json').toBe(0).run(d)
# print(a)
# print(a.run_log)
# print(a.res)


for i in range(13800500,13800630):
    tel=str(i*1000)
    a=item('注册','http',fetch("https://paytest.ciicsh.com/auth/authenticate/register", {
    "headers": {
        "accept": "application/json, text/plain, */*",
        "accept-language": "zh-CN,zh;q=0.9",
        "content-type": "application/json;charset=UTF-8",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-origin"
    },
    "referrer": "https://paytest.ciicsh.com/register",
    "referrerPolicy": "no-referrer-when-downgrade",
    "body": "{\"companyName\":\""+tel+"\",\"corporationName\":\""+tel+"\",\"socialUnifiedCreditCode\":\""+tel+"\",\"businessRegistrationNumber\":\"\",\"taxIdentificationNumber\":\"\",\"orgCode\":\"\",\"scaleEnterprise\":4,\"classification\":6,\"authType\":\"2\",\"phone\":\""+tel+"\",\"password\":\"AAAaaa111\",\"code\":\""+tel+"\"}",
    "method": "POST",
    "mode": "cors",
    "credentials": "include"
    })).expect('data.code').toBe(0).run(d)
    # print(i,a)
    if a.status!='成功':
        print(a.res)
